#include <iostream>

class Complex
{
public:
    friend std::ostream& operator<<(std::ostream &os, const Complex & c);
    friend std::istream& operator>>(std::istream &is, Complex & c);

    Complex(int real, int vir):real(real), vir(vir){}

    Complex operator+(const Complex & c)
    {
        Complex result(0, 0);
        result.real = this->real + c.real;
        result.vir = this->vir + c.vir;
        return result;
    }
    Complex operator-(const Complex & c)
    {
        Complex result(0, 0);
        result.real = this->real - c.real;
        result.vir = this->vir - c.vir;
        return result;
    }

    Complex operator++()//c++ 前置
    {
        this->real++;
        this->vir++;
        return * this;

    }

    Complex operator++(int)//++c 后置++ 占位参数
    {
        Complex temp = *this;
        this->real++;
        this->vir++;
        return temp;
    }
    // void show()
    // {
    //     if (vir != 0)
    //         std::cout<<real<<"+"<<vir<<"i"<<std::endl;
    //     else
    //         std::cout<<real<<std::endl;
    // }
private:
    int real;
    int vir;

};

std::ostream& operator<<(std::ostream &os, const Complex & c)
{
    if (c.vir != 0)
        os<<c.real<<"+"<<c.vir<<"i";
    else
        os<<c.real;
    return os;
}

std::istream& operator>>(std::istream &is, Complex & c)
{
    is>>c.real>>c.vir;
    return is;
}

int main()
{
    Complex c(2, 1);
    Complex c1(3, 2);
    Complex c2 (0, 0);


    
    //c2.show();
    //std::cin>>c2;
    std::cout<<c1<<std::endl;
    std::cout<<++c1<<std::endl;

    std::cout<<c<<std::endl;
    std::cout<<c++<<std::endl;
    std::cout<<c<<std::endl;


    return 0;
}
